﻿using System;
using System.CodeDom;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace eSSP_example.Cpi
{
    public class ReturnValue
    {
        // --- general / API related ---
        public const int RET_SUCCESS = 0;  ///< Return value: Success
        public const int RET_ERROR_API_NOT_STARTED = 0x1000;  ///< Return value: The API is not started    
        public const int RET_ERROR_OTHER_REQUEST_CURRENTLY_ACTIVE = 0x1001;  ///< Return value: Another request is currently being processed  
        public const int RET_ERROR_DEVICE_OFFLINE = 0x1002;  ///< Return value: Device is not connected / turned on
        public const int RET_ERROR_DEVICE_WENT_OFFLINE = 0x1003;  ///< Return value: Device went offline during operation
        public const int RET_ERROR_DEVICE_NOT_IN_READY_STATE = 0x1004;  ///< Return value: The device is not in "READY" state
        public const int RET_ERROR_ILLEGAL_REQUEST = 0x1005;  ///< Return value: Unknown request or not allowed now
        public const int RET_ERROR_DEVICE_COULD_NOT_HANDLE = 0x1006;  ///< Return value: Device could not handle this request at this time
        public const int RET_ERROR_EVENT_NOT_FOUND = 0x1007;  ///< Return value: Event code not found
        public const int RET_ERROR_DEVICE_IN_ERROR_STATE = 0x1008;  ///< Return value: Device is in "ERROR" state  //review impl, document!
        public const int RET_ERROR_INVALID_ARGUMENTS = 0x1009;  ///< Return value: Passed arguments was invalid for api call

        // --- dispense related ---
        public const int RET_ERROR_DISPENSE_REQUEST_FAILED = 0x2000;  ///< Return value: Dispense request failed, check inventory
        public const int RET_ERROR_UNEXPECTED_STATE_DURING_PAY_OUT = 0x2001;  ///< Return value: An unexpected device state occurred during pay-out
        public const int RET_ERROR_WHILE_DISPENSING_COINS = 0x2002;  ///< Return value: The dispense operation could not be completed, check events for errors
        public const int RET_ERROR_INVALID_HOPPER_NO = 0x2003;  ///< Return value: Invalid hopper number specified
        public const int RET_ERROR_INVALID_COIN_TYPE = 0x2004;  ///< Return value: Invalid coin type specified / no hopper assigned to

        // --- acceptance related ---
        public const int RET_ERROR_INSERTION_REQUEST_FAILED = 0x3000;  ///< Return value: The device denied the request for "INSERTION" state
        public const int RET_ERROR_UNEXPECTED_STATE_DURING_PAY_IN = 0x3001;  ///< Return value: An unexpected device state occurred during pay-in
        public const int RET_ERROR_DISABLING_ACCEPTANCE_DENIED = 0x3002;  ///< Return value: The device could not return from "ACCEPTANCE" state  

       
        public static string getStrReturnValue(int result)
        {
            switch (result)
            {
                case RET_SUCCESS:
                    ///< Return value: Success
                    return "RET_SUCCESS";

                case RET_ERROR_API_NOT_STARTED:
                    ///< Return value: The API is not started    
                    return "RET_ERROR_API_NOT_STARTED";

                case RET_ERROR_OTHER_REQUEST_CURRENTLY_ACTIVE:
                    ///< Return value: Another request is currently being processed  
                    return "RET_ERROR_OTHER_REQUEST_CURRENTLY_ACTIVE";

                case RET_ERROR_DEVICE_OFFLINE:
                    ///< Return value: Device is not connected / turned on
                    return "RET_ERROR_DEVICE_OFFLINE";

                case RET_ERROR_DEVICE_WENT_OFFLINE:
                    ///< Return value: Device went offline during operation
                    return "RET_ERROR_DEVICE_WENT_OFFLINE";

                case RET_ERROR_DEVICE_NOT_IN_READY_STATE:
                    ///< Return value: The device is not in "READY" state
                    return "RET_ERROR_DEVICE_NOT_IN_READY_STATE";

                case RET_ERROR_ILLEGAL_REQUEST:
                    ///< Return value: Unknown request or not allowed now
                    return "RET_ERROR_ILLEGAL_REQUEST";

                case RET_ERROR_DEVICE_COULD_NOT_HANDLE:
                    ///< Return value: Device could not handle this request at this time
                    return "RET_ERROR_DEVICE_COULD_NOT_HANDLE";

                case RET_ERROR_EVENT_NOT_FOUND:
                    ///< Return value: Event code not found
                    return "RET_ERROR_EVENT_NOT_FOUND";

                case RET_ERROR_DEVICE_IN_ERROR_STATE:
                    ///< Return value: Device is in "ERROR" state  //review impl, document!
                    return "RET_ERROR_DEVICE_IN_ERROR_STATE";

                case RET_ERROR_INVALID_ARGUMENTS:
                    ///< Return value: Passed arguments was invalid for api call
                    return "RET_ERROR_INVALID_ARGUMENTS";

                // --- dispense related ---
                case RET_ERROR_DISPENSE_REQUEST_FAILED:
                    ///< Return value: Dispense request failed, check inventory
                    return "RET_ERROR_DISPENSE_REQUEST_FAILED";

                case RET_ERROR_UNEXPECTED_STATE_DURING_PAY_OUT:
                    ///< Return value: An unexpected device state occurred during pay-out
                    return "RET_ERROR_UNEXPECTED_STATE_DURING_PAY_OUT";

                case RET_ERROR_WHILE_DISPENSING_COINS:
                    ///< Return value: The dispense operation could not be completed, check events for errors
                    return "RET_ERROR_WHILE_DISPENSING_COINS";

                case RET_ERROR_INVALID_HOPPER_NO:
                    ///< Return value: Invalid hopper number specified
                    return "RET_ERROR_INVALID_HOPPER_NO";

                case RET_ERROR_INVALID_COIN_TYPE:
                    ///< Return value: Invalid coin type specified / no hopper assigned to
                    return "RET_ERROR_INVALID_COIN_TYPE";

                // --- acceptance related ---
                case RET_ERROR_INSERTION_REQUEST_FAILED:
                    ///< Return value: The device denied the request for "INSERTION" state
                    return "RET_ERROR_INSERTION_REQUEST_FAILED";

                case RET_ERROR_UNEXPECTED_STATE_DURING_PAY_IN:
                    ///< Return value: An unexpected device state occurred during pay-in
                    return "RET_ERROR_UNEXPECTED_STATE_DURING_PAY_IN";

                case RET_ERROR_DISABLING_ACCEPTANCE_DENIED:
                    ///< Return value: The device could not return from "ACCEPTANCE" state 
                    return "RET_ERROR_DISABLING_ACCEPTANCE_DENIED";

                default:
                    return "Unknown Return Values";
            }
        }
    }
}
